/****************************************************
 * @class FURSelectionWindow
 * @extends Ext.Window
 ***************************************************/
	FURSelectionWindow = Ext.extend(Ext.Window,{
		furSelectionGrid: null,
		txtfld: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			FURSelectionWindow.superclass.constructor.call(this, {
				layout: 'fit',
				width: 420,
				height: 480,
				modal: true,
				plain: true,
				resizable: false,
				closeAction: 'hide',
				buttonAlign: 'center',
				items: this.furSelectionGrid,
				buttons: [{
					text: "确定",
					scope: this,
					handler: function(){
						var record = this.furSelectionGrid.getSelectionModel().getSelected();
						var log_user = Ext.fly("login_user").dom.value;
						Ext.fly(this.txtfld).dom.value = record.get("trackingNumber");
						
						var copyMask = new Ext.LoadMask(Ext.getBody(), {
							msg: "更新信息中，请稍后...",
							removeMask: true
						});
						
						copyMask.show();
						
						jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
						try{
							var info = jsonrpc.jabsorbService.getDispatchUrl(record.get("trackingNumber"),log_user,"PM.FUR");
						}catch(e){
							alert(e);
						}
						
						var panel = Ext.getCmp("ext_furInfo");
						panel.destroy();
						
						copyMask.hide();
						panel = new Ext.Panel({
							id: "ext_furInfo",
							title: "页面信息",
							height: 480,
							autoDestroy: true,
							html: '<iframe src="http://myivo.ivo.com.cn/Arcadia/servlet/WebDispatcher?mailCode='+info+'" width="100%" height="100%" frameborder=1 scrolling=auto></iframe>'
						});
						
						panel.setTitle("[" + record.get("trackingNumber") + "] 页面信息");
						panel.render("div_FurInfo");
						
						this.hide();
					}
				},{
					text: "关闭",
					scope: this,
					handler: function(){
						this.hide();
					}
				}]
			});
		},
		load: function(){
			this.furSelectionGrid.store.load();
		}
	});
/****************************************************
 * @class FURSelectionGridPanel
 * @extends Ext.grid.GridPanel
 ***************************************************/
	FURSelectionGridPanel = Ext.extend(Ext.grid.GridPanel,{
		condition: null,
		store: null,
		cm: null,
		searchField: null,
		txtfld: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			this.condition = {};
			this.condition.limit = 50;
			
			this.store = new Ext.data.Store({
			    baseParams: this.condition,   
				proxy: new Ext.data.HttpProxy({
					method: 'POST',
					url: '/pdm/pm/getFURList.htm'
				}),
				reader: new Ext.data.JsonReader({
					totalProperty: 'totalProperty',
					root: 'root',
					id: 'followUpRequisition_ID'
				},[
					{name: 'followUpRequisition_ID'},
					{name: 'trackingNumber'},
					{name: 'requisitioner'},
					{name: 'memo'}
				])
			});
			
			this.cm = new Ext.grid.ColumnModel([
		        {
		           header: "签核单号",
		           dataIndex: 'trackingNumber',
		           sortable: true,
		           width: 80
		        },{
		           header: "起草人",
		           dataIndex: 'requisitioner',
		           sortable: true,
		           width: 80
		        },{
		           header: "摘要",
		           dataIndex: 'memo',
		           sortable: true,
		           width: 100,
		           renderer: renderGridStr
		        }]);
	        
			this.searchField = new Ext.ux.form.SearchField({store: this.store, width:200});
			
			FURSelectionGridPanel.superclass.constructor.call(this, {
			    loadMask: {msg: "信息载入中..."},
			    viewConfig: {forceFit: true},
				region: 'center',
				border: false,
				height: 500,
				layout: 'fit',
				split: true,
				stripeRows: true,
				ds: this.store,
				sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
				cm: this.cm,
				trackMouseOver: false,
				tbar: ["查询：", this.searchField],
				bbar: new Ext.PagingToolbar({
					pageSize: 50,
					store: this.store,
					displayInfo: true
				})
			});
			
			this.on('rowdblclick', function(grid, rowIndex, e) {
				var r = grid.getSelectionModel().getSelected();
				Ext.fly(this.txtfld).dom.value = r.get("trackingNumber");
				var log_user = Ext.fly("login_user").dom.value;
				
				var copyMask = new Ext.LoadMask(Ext.getBody(), {
					msg: "更新信息中，请稍后...",
					removeMask: true
				});
				
				copyMask.show();
				
				jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
				try{
					var info = jsonrpc.jabsorbService.getDispatchUrl(r.get("trackingNumber"),log_user,"PM.FUR");
				}catch(e){
					alert(e);
				}
				var panel = Ext.getCmp("ext_furInfo");
				panel.destroy();
				
				panel = new Ext.Panel({
					id: "ext_furInfo",
					title: "页面信息",
					height: 480,
					autoDestroy: true,
					html: '<iframe src="http://myivo.ivo.com.cn/Arcadia/servlet/WebDispatcher?mailCode='+info+'" width="100%" height="100%" frameborder=1 scrolling=auto></iframe>'
				});
				
				panel.setTitle("[" + r.get("trackingNumber") + "] 页面信息");
				panel.render("div_FurInfo");
				
				Ext.getCmp("ext_selectionWin").hide();
				
				copyMask.hide();
			});
		}
	});